package com.tushare.service.impl;

import com.tushare.entity.Daily;
import com.tushare.mapper.DailyMapper;
import com.tushare.service.IDailyService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author jobob
 * @since 2021-03-08
 */
@Service
public class DailyServiceImpl extends ServiceImpl<DailyMapper, Daily> implements IDailyService {

    @Override
    public Daily getLastDaily() {
        return getBaseMapper().getLastDaily();
    }

    @Override
    public List<Daily> getDailyListByTsCode(String ts_code, int trade_date) {
        return getBaseMapper().getDailyListByTsCode(ts_code, trade_date);
    }

    @Override
    public Daily getLastDailyByTsCode(String ts_code) {
        return getBaseMapper().getLastDailyByTsCode(ts_code);
    }

    @Override
    public boolean saveDailies(List<Daily> list) {
        if (list == null) {
            return false;
        }
        if (list.size() == 0) {
            return true;
        }
        return getBaseMapper().saveOrUpdateBatch(list);
    }

    @Override
    public boolean deleteAllDaily() {
        return getBaseMapper().deleteAllDaily();
    }
}
